'use strict';
import React from 'react';
import { StyleSheet, TextInput } from 'react-native';


class CusTextInput extends React.PureComponent {

    static propTypes = {
        ...TextInput.propTypes
    }

    static defaultProps = {
        ...TextInput.defaultProps
    }

    constructor(props) {
        super(props)
    }

    _onChangeText = (text) => {
        const { onChangeText, value } = this.props;
        if (value && __IOS__) {
            // 不调用
        } else {
            onChangeText && onChangeText(text)
        }
    }

    _onBlur = (event) => {
        const { onChangeText, onBlur, value } = this.props;
        if (value && __IOS__) {
            onChangeText && onChangeText(event.nativeEvent.text)
        }
        onBlur && onBlur(event)
    }

    render() {
        const { onChangeText, onBlur, ...others } = this.props;
        return (
            <TextInput
                onChangeText={this._onChangeText}
                onBlur={this._onBlur}
                underlineColorAndroid={'transparent'}
                {...others}
            />
        )
    }
}

const styles = StyleSheet.create({

});

export default CusTextInput